<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@include file="init.jsp" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Add Product</title>
</head>
<body>
<div class="master-wrapper-content">
	<jsp:include page="heading.jsp"></jsp:include>
	<%
		System.out.println(session.getAttribute("roleId"));
		if(session.getAttribute("roleId") == null || String.valueOf(session.getAttribute("roleId")).equalsIgnoreCase("2")) {
			%>
				<h3 style="color: red">Không đủ quyền để truy cập</h3>
			<%
		}
		else {
	%>
			<jsp:include page="CategoryAdmin.jsp"></jsp:include>
			<div class="container-right">
				<form method="post" action="AddProduct" enctype="multipart/form-data">
					<table>
						<tr>
							<td>Product Name : </td>
							<td><input type="text" name="productName" /></td>
						</tr>
						<tr>
							<td>Image : </td>
							<td><input type="file" name="productImage" /></td>
						</tr>
						<tr>
							<td>Description : </td>
							<td>
								<textarea rows="5" cols="25" name="description"></textarea>
							</td>
						</tr>
						<tr>
							<td>Price : </td>
							<td><input type="text" name="price" /></td>
						</tr>
						<tr>
							<td>Quantity</td>
							<td><input type="text" name="quantity" /></td>
						</tr>
						<tr>
							<td>Producer : </td>
							<td>
								<%
									List<Producer> producers = dataManager.getAllProducer();
									List<Category> categorys = dataManager.getAllCategory();
								%>
								<select name="producerId">
									<%
										for(Producer producer : producers) {							
											%>
												<option value="<%=producer.getProducerId() %>"><%=producer.getProducerName() %></option>
											<%						
										}
									%>
								</select>
							</td>
						</tr>
						<tr>
							<td>Category : </td>
							<td>
								<select name="categoryId">
									<%
										for(Category category : categorys) {
											%>
												<option value="<%=category.getCategoryId() %>"><%=category.getCategoryName() %></option>
											<%							
										}
									%>
								</select>
							</td>
						</tr>
					</table>
					<br />
					<input type="submit" value="Add Product" />
				</form>
			</div>
			<div class="clear"></div>
			<%
			} 
			%>
		<jsp:include page="footer.jsp"></jsp:include>
	</div>
</body>
</html>